// app.js
App({
  onLaunch() {
    wx.cloud.init({env: 'cloud1-0ghqkz46f7bed848'});
    var appObj = this;
    //登录
    wx.cloud.callFunction({
      name: 'getContext',
      complete: res => {
        //获取用户openid
        appObj.globalData.openid = res.result.openid
      }
    })
    wx.getStorageSync({
      key: "grade",
      success: function(res) {
        if (res.data != "") {
          appObj.globalData = res.data
        }
      }
    })
  },
  onHide() {
    var appObj = this;
    wx.setStorageSync({
      key: "grade",
      data: appObj.globalData.grade
    })
  },
  globalData: {
    userInfo: null,
    hasUserInfo: false,
    grade: 0,
    openid: ''
  }
})
